#pragma once

#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>

#define FIFO_FILE "./mypiped"
#define MODE 0664
#define SIZE 1024

enum 
{
    FIFO_CREAT_ERR = 1 ,
    FIFO_OPEN_ERR      ,
    FIFO_READ_ERR      ,
    FIFO_WRITE_ERR     ,
    FIFO_DELETE_ERR
};


class pipe_init
{
public:
pipe_init()
    {
        int n = mkfifo(FIFO_FILE,MODE);
        if(n < 0){
        perror("mkfifo");
        exit(FIFO_CREAT_ERR);
        }
    }

    ~pipe_init(){
        int m = unlink(FIFO_FILE);
        if (m == -1)
        {
            perror("unlink");
            exit(FIFO_DELETE_ERR);
        }
    }
};